﻿using Net_SCADA.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Net_SCADA
{
    public partial class Form_MessageBox : fdBaseForm
    {
        string msgTitle;//标题
        string msgContent;//显示的文本内容
        string msgSubContentLeft;//附加信息文本
        string msgSubContentRight;//附件信息内容
        FontFamily[] fontFamily = new FontFamily[] { new FontFamily("Microsoft YaHei"), new FontFamily("Arial") };
        int btnType;
        public Form_MessageBox(string title,string content,int btns,string subContentLeft, string subContentRight)
        {
            InitializeComponent();
            formLanguageIndex = -1;
            msgTitle = title;
            msgContent = content;
            msgSubContentLeft = subContentLeft;
            msgSubContentRight = subContentRight;
            btnType = btns;
        }

        private void Form_MessageBox_Activated(object sender, EventArgs e)
        {
            if (formLanguageIndex != MultipleLanguage.systemLanguageIndex)
            {
                formLanguageIndex = MultipleLanguage.systemLanguageIndex;
                MultipleLanguage.switchLanguage(this);

            }

            lblTitle.Text = msgTitle;
            lblContent.Text = msgContent;
            lblSubContentLeft.Text = msgSubContentLeft;
            lblSubContentRight.Text = msgSubContentRight;   
            switch (btnType)
            {
                case 1://ok only
                    btnCancel.Visible = false;
                    break;
                case 2://okcancel
                    btnCancel.Visible = true;
                    break;
                default:
                    btnCancel.Visible = false;
                    break;
            }
        }


        private void btnOK_Click(object sender, EventArgs e)
        {
            fdMessage.DealMessage(1);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            fdMessage.DealMessage(2);
        }

        private void Form_MessageBox_Load(object sender, EventArgs e)
        {
            foreach (Control item in this.Controls)
            {
                item.Font = new Font(fontFamily[formLanguageIndex], item.Font.Size);
            }
        }
    }
}
